// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Q3D_CPPE_PropertyName.h"
#include "Q3D_CPPU_PropertyPLIBase.generated.h"

class UQ3D_CPPU_PropertyPLIBase;

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FQ3D_D_Value_Reset, UQ3D_CPPU_PropertyPLIBase *, ptr_u_property_pli_base);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FQ3D_D_Value_ReachMin, UQ3D_CPPU_PropertyPLIBase *, ptr_u_property_pli_base);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FQ3D_D_Value_ReachMax, UQ3D_CPPU_PropertyPLIBase *, ptr_u_property_pli_base);

/**
 * 
 */
UCLASS(Blueprintable, ClassGroup = (Q3D), meta = (Tooltip = "有限正整数属性基础类(C++)"))
class Q3D_LIB_API UQ3D_CPPU_PropertyPLIBase : public UObject
{
	GENERATED_BODY()

public:
	UQ3D_CPPU_PropertyPLIBase();
	virtual ~UQ3D_CPPU_PropertyPLIBase();

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "属性名", ExposeOnSpawn = "true"))
	EQ3D_CPPE_PropertyName Enum_PropertyName;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "属性值"))
	int32 Int_Value;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "最小值"))
	int32 Int_Min;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "最大值"))
	int32 Int_Max;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "Value 占 Max 的百分比"))
	float Float_Percent;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "Value 占 Max 的百分比 x 100"))
	int32 Int_Percent;

protected:
	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "工具函数：用以检查输入值并返回合规值"))
	void _F_Limit_Check(int32 int_value_in, UPARAM(DisplayName = "int_value_out") int32 &int_value_out, UPARAM(DisplayName = "bool_changed") bool &bool_change) const;

private:
	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "工具函数：确保 Max >= Value >= Min >= 0，可能会重置 Value"))
	void _F_Value_Reset(UPARAM(DisplayName = "string_log") FString &string_log);

public:
	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "设置 Min 和 Max，确保 Max >= Value >= Min >= 0"))
	virtual void Q3D_F_Limit_Set(int32 int_min_in, int32 int_max_in, UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "设置 Max，确保 Max >= Value >= Min >= 0"))
	virtual void Q3D_F_Max_Set(int32 int_max_in, UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "设置 Max，确保 Max >= Value >= Min >= 0，并按原有比例修改 Value"))
	virtual void Q3D_F_Max_SetScale(int32 int_max_in, UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "减少 Value，并限定在 Min 和 Max的区间内"))
	virtual void Q3D_F_Value_Dec(int32 int_value_dec);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "增加 Value，并限定在 Min 和 Max 的区间内"))
	virtual void Q3D_F_Value_Inc(int32 int_value_inc);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "设置 Value，并限定在 Min 和 Max 的区间内"))
	virtual void Q3D_F_Value_Set(int32 int_value_in);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "在 Min 和 Max 区间内设置 Value 为随机值"))
	virtual void Q3D_F_Value_SetRandom();

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "委托函数，设置 Max，确保 Max >= Value >= Min >= 0"))
	void Q3D_FD_Max_Set(UQ3D_CPPU_PropertyPLIBase *ptr_u_property_pli_base);

	UFUNCTION(BlueprintCallable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "委托函数，设置 Max，确保 Max >= Value >= Min >= 0，并按原有比例修改 Value"))
	void Q3D_FD_Max_SetScale(UQ3D_CPPU_PropertyPLIBase *ptr_u_property_pli_base);

	UFUNCTION(BlueprintPure, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "以 (Min,Max,Value) 的格式输出"))
	void Q3D_F_ToString(UPARAM(DisplayName = "string_min_max_base") FString &string_min_max_base) const;
	FString Q3D_F_ToString() const;

public:
	UPROPERTY(BlueprintAssignable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "多播代理：Value 重置"))
	FQ3D_D_Value_Reset Q3D_ED_Value_Reset;

	UPROPERTY(BlueprintAssignable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "多播代理：Value 达到了 Min"))
	FQ3D_D_Value_ReachMin Q3D_ED_Value_ReachMin;

	UPROPERTY(BlueprintAssignable, Category = Q3D_PropertyPLIBase, meta = (Tooltip = "多播代理：Value 达到了 Max"))
	FQ3D_D_Value_ReachMax Q3D_ED_Value_ReachMax;
};
